﻿using MediatR;
using StoreISet.Applicationes.Command;
using StoreRepositorys.Interface;

namespace StoreISet.Applicationes.CommandHandler
{
    /// <summary>
    /// 上传图片删除
    /// </summary>
    public class PictureDeleteCommandler : IRequestHandler<PictureDeleteCommand, int>
    {
        public readonly IPictureRepository _pictureRepository;
        public PictureDeleteCommandler(IPictureRepository pictureRepository)
        {
            _pictureRepository = pictureRepository;
        }

        public async Task<int> Handle(PictureDeleteCommand request, CancellationToken cancellationToken)
        {
            try
            {
                return await _pictureRepository.Deleteasync(request.PictureId);
            }
            catch (Exception)
            {

                throw;
            }
            
        }
    }
}
